package com.evildog.workspace.generator.runner;


import com.evildog.workspace.generator.gene.DefaultGenerator;

public class DefaultGeneratorRunner {

    public static void main(String[] args) {
//        run();
//        partRun();
        oneTableRun();
    }


    /**
     * 生成所有表
     * module不一样的话，建议使用 partRun
     */
    public static void run() {
        DefaultGenerator defaultGenerator = new DefaultGenerator();
        defaultGenerator.run(true);
    }

    private static void oneTableRun() {
        DefaultGenerator defaultGenerator = new DefaultGenerator();
        defaultGenerator.setPackageDir("D://mycode2");

        defaultGenerator.setServiceName("workspace-system");
        defaultGenerator.setModuleName("system");
        defaultGenerator.setHasSuper(true);

        defaultGenerator.setUrl("jdbc:mysql://localhost:3306/ws_system?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8");
        defaultGenerator.setIncludeTables(new String[]{
                "sys_api_permission_category"
        });

//        defaultGenerator = new DefaultGenerator();
//        defaultGenerator.setServiceName("workspace-life");
//        defaultGenerator.setModuleName("life");
//        defaultGenerator.setHasSuper(true);
//        defaultGenerator.setEditAble(2);
//        defaultGenerator.setUrl("jdbc:mysql://localhost:3306/ws_life?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8");
//        defaultGenerator.setIncludeTables(new String[]{
//                "life_album",
//                "life_photo",
//        });

        defaultGenerator.run(true);
    }

    /**
     * 生成指定表
     */
    public static void partRun() {
        try{
            DefaultGenerator defaultGenerator = new DefaultGenerator();
            defaultGenerator.setUsername("root");
            defaultGenerator.setPassword("root");

            defaultGenerator.setServiceName("workspace-invest");
            defaultGenerator.setModuleName("invest");
            defaultGenerator.setHasSuper(true);
            defaultGenerator.setUrl("jdbc:mysql://localhost:3306/ws_invest?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8");
            defaultGenerator.run(false);

            defaultGenerator = new DefaultGenerator();
            defaultGenerator.setServiceName("workspace-system");
            defaultGenerator.setModuleName("system");
            defaultGenerator.setUrl("jdbc:mysql://localhost:3306/ws_system?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8");
            defaultGenerator.setHasSuper(true);
            defaultGenerator.run(false);


            defaultGenerator = new DefaultGenerator();
            defaultGenerator.setServiceName("workspace-life");
            defaultGenerator.setUrl("jdbc:mysql://localhost:3306/ws_life?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8");
            defaultGenerator.setModuleName("life");
            defaultGenerator.setHasSuper(true);

            defaultGenerator.run(true);
        }catch (Exception e){

        }
    }




}
